package com.ddh.ddhsanguogame.exception;

import lombok.Getter;

@Getter
public enum ErrorCode {

    // 0xxx: 成功和通用错误
    SUCCESS(0, "ok"),
    PARAMS_ERROR(40000, "请求参数错误"),
    USERNAME_EMPTY_ERROR(40002, "用户名不能为空"),
    PASSWORD_EMPTY_ERROR(40003, "密码不能为空"),
    NICKNAME_EMPTY_ERROR(40004, "昵称不能为空"),
    AVATAR_URL_INVALID(40005, "头像地址不合法"),
    REPEAT_REQUEST(40006, "重复请求，请勿频繁操作"),
    USER_EXIST_ERROR(50002, "用户已存在"),
    PASSWORD_ERROR(40007, "密码错误"),
    ALLIANCE_NAME_DUPLICATE_ERROR(40008, "同盟名称不能重复"),
    USER_ALREADY_HAS_ALLIANCE(40009, "用户已经创建过同盟"),

    // 4xxx: 客户端错误
    NOT_LOGIN_ERROR(40100, "未登录"),
    NO_AUTH_ERROR(40101, "无权限"),
    NOT_FOUND_ERROR(40400, "请求数据不存在"),
    FORBIDDEN_ERROR(40300, "禁止访问"),
    UNAUTHORIZED_OPERATION(40301, "无权限执行此操作"),
    RESOURCE_NOT_FOUND(40401, "资源不存在"),

    // 5xxx: 服务器错误
    SYSTEM_ERROR(50000, "系统内部异常"),
    OPERATION_ERROR(50001, "操作失败"),
    DATABASE_ERROR(50002, "数据库操作异常"),
    DATA_CONVERSION_ERROR(50003, "数据转换异常"),
    FILE_UPLOAD_FAILED(50004, "文件上传失败"),
    USER_NOT_FOUND_ERROR(500005, "用户不存在"),
    PRIVATE_MESSAGE_REQUIRES_RECEIVER_ID(500006, "私聊消息必须包含接收者ID");

    /**
     * 状态码
     */
    private final int code;

    /**
     * 信息
     */
    private final String message;

    ErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }
}
